home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXT Education Software Sampler 1992 Fall
/
NeXT Education Software Sampler 1992 Fall.iso
/
SoundAndMusic
/
cmix
/
Minc
/
print.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-03-16
|
2KB
|
110 lines
#include <stdio.h>
/*
* file: print.c
*
* This file contains a function that is an internally defined function
* to print to standard output.
*/
is_print(str,a,n)
char *str;
double a[];
int n;
{
int i;
char *s;
char buf[500],*cp,c;
cp = buf;
if (!strcmp(str,"print")|| !strcmp(str,"printf")) {
i = (int) a[0];
s = (char *) i;
if (n >40) {
fprintf(stderr,"ERROR: exceeded maximum number of args to print\n");
return(1);
}
for (i=0;s[i]!='\0';i++) {
if (i >= 500) {
fprintf(stderr,"ERROR: exceeded maximum command string length in print\n");
return(1);
}
c = s[i];
switch(c) {
case '\\':
i++;
c = s[i];
switch (c) {
case 'n':
*cp++ = '\n';
break;
case 't':
*cp++ = '\t';
break;
case '\\':
*cp++ = '\\';
break;
case '%':
*cp++ = '%';
break;
}
break;
case '%':
i++;
c = s[i];
*cp++ = '%';
switch (c) {
case 'f':
*cp++ = 'f';
break;
case 'd':
*cp++ = 'f';
break;
case 'l':
*cp++ = 'f';
break;
case ' ':
*cp++ = 'f';
*cp++ = ' ';
break;
case ',':
*cp++ = 'f';
*cp++ = ',';
break;
}
break;
default:
*cp++ = c;
break;
}
}
*cp++ = '\0';
printf(buf,
a[ 1],a[ 2],a[ 3],a[ 4],a[ 5],a[ 6],a[ 7],a[ 9],a[ 10],
a[ 11],a[ 12],a[ 13],a[ 14],a[ 15],a[ 16],a[ 17],a[ 19],a[ 20],
a[ 21],a[ 22],a[ 23],a[ 24],a[ 25],a[ 26],a[ 27],a[ 29],a[ 30],
a[ 31],a[ 32],a[ 33],a[ 34],a[ 35],a[ 36],a[ 37],a[ 39],a[ 40]);
return(1);
}
return(0);
}